package com.hd.trans.utils;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

import com.hd.trans.ui.base.AppContextProvider;

public class DeviceUtil {

    /**
     * 获取设备的唯一标识，deviceId
     *
     * @param context
     * @return
     */
    public static String getDeviceId(Context context) {
        return AndroidUtil.getAndroidIdHuDun(context);
    }
    public static String getDeviceId() {
        return AndroidUtil.getAndroidIdHuDun(AppContextProvider.getContext());
    }

    /**
     * 获取应用程序名称
     */
    public static String getAppName(Context context) {
        try {
            PackageManager packageManager = AppContextProvider.getContext().getPackageManager();
            PackageInfo packageInfo = packageManager.getPackageInfo(AppContextProvider.getContext().getPackageName(), 0);
            int labelRes = packageInfo.applicationInfo.labelRes;
            return AppContextProvider.getContext().getResources().getString(labelRes);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        return null;
    }
}